import http from '@/utils/service';

const API = {
  LoginApi: '/user/login',
  SendSMSApi: '/user/sendSMS',
  getMonthCost: '/user/getMonthCost',
  getRestaurantOrder: '/order/getRestaurantOrder?UserId=',
  getUser: '/user/getUser',
};

export interface LoginInter {
  loginAcc: string;
  loginPwd: string;
}
export interface RestaurantOrder {
  list: {
    number: number;
    restaurantName: string;
  }[];
}

export interface getUser {
  list: {
    id: number;
    account: string;
    userName: string;
    role: number;
  }[];
}

export interface DataType {
  id: number;
  account: string;
  userName: string;
  role: number;
  state: number;
}

export interface getUserPage {
  name: string;
  current: number;
  size: number;
  sortField: string;
  sortOrder: string;
}

export const LoginApi = (data: LoginInter) => http.post(API.LoginApi, { data });

export const SendSMSApi = (phone: string) =>
  http.get(API.SendSMSApi, { params: { phone } });

export const getMonthCostApi = (userId: number) =>
  http.get(API.getMonthCost + `?userId=${userId}`);

export const getRestaurantOrderApi = (restaurantId: number) =>
  http.get(API.getRestaurantOrder + restaurantId);

export const getUserApi = (data: getUserPage) =>
  http.post(API.getUser, { data });
